import http from '@/api/http.js'
export default {
    sysMangerList(data, cb, error) {
        data['order'] = ''
        data['orderField'] = ''
        http.$post('sysMangerList', { data: data }).then(res => {
            cb(res)
        })
    },
    DictionaryTableList(data, cb, error) {
        data['order'] = ''
        data['orderField'] = ''
        http.$post('DictionaryTableList', { data: data }).then(res => {
            cb(res)
        })
    },
    DictionaryTypedataTree(data, cb, error) {
        http.$post('DictionaryTypedataTree', { data: data }).then(res => {
            if (res.code == 200) {
                cb(res)
            }
        })
    },
    roleAuthenMenuTree(data, cb, error) {
        http.$get('roleAuthenMenuTree', { params: data }).then(res => {
            if (res.code == 200) {
                function setTreeData(list) {
                    list.forEach(item => {
                        item.title = item.label;
                        item.checked = false;
                        item.pid == 0 && (item.expand = true);
                        if (item.children && item.children.length > 0) {
                            setTreeData(item.children);
                        }
                    })
                }
                setTreeData(res.data.authen);
                setTreeData(res.data.function);

                cb(res.data)
            }
        })
    },


    roleList(data, cb, error) {
        http.$get('roleList', { params: data }).then(res => {
            if (res.code == 200) {
                let arr = [];
                for (let j = 0; j < res.data.length; j++) {
                    arr.push({
                        value: res.data[j].id,
                        label: res.data[j].name
                    })
                }
                cb(arr)
            }
        })
    },
    ParameterTableList(data, cb, error) {
        data['order'] = ''
        data['orderField'] = ''
        http.$post('ParameterTableList', { data: data }).then(res => {
            cb(res)
        })
    },
    permissionUserManage(data, cb, error) {
        data['order'] = ''
        data['orderField'] = ''
        http.$post('permissionUserManage', { data: data }).then(res => {
            cb(res)
        })
    },
    permissionRolePageByUser(data, cb, error) {
        http.$post('permissionRolePageByUser', { data: data }).then(res => {
            cb(res)
        })
    },
    Informationconfig(data, cb, error) {
        data['type'] = data.type ? Object.prototype.toString.call(data.type) === "[object Array]" ? data.type : [data.type] : ['0', '1', '2', '3']
        data['order'] = ''
        data['orderField'] = ''
        data['releaseDateStart'] = data.releaseDate ? data.releaseDate[0] == '' ? null : data.releaseDate[0] : null
        data['releaseDateEnd'] = data.releaseDate ? data.releaseDate[1] == '' ? null : data.releaseDate[1] : null
        http.$post('Informationconfig', { data: data }).then(res => {
            cb(res)
        })
    },
    InformationconfigNotice(data, cb, error) {
        data['type'] = ['4', '5']
        data['order'] = ''
        data['orderField'] = ''
        data['releaseDateStart'] = data.releaseDate ? data.releaseDate[0] == '' ? null : data.releaseDate[0] : null
        data['releaseDateEnd'] = data.releaseDate ? data.releaseDate[1] == '' ? null : data.releaseDate[1] : null
        http.$post('Informationconfig', { data: data }).then(res => {
            cb(res)
        })
    },
    DocumentPage(data, cb, error) {
        data['order'] = ''
        data['orderField'] = ''
        http.$post('DocumentPage', { data: data }).then(res => {
            cb(res)
        })
    },
}